package com.platform.uaa.service;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.time.LocalDateTime;
import java.util.Collection;

/**
 * 描述：自定义UserDetails，使UserDetails具有TUser的实体结构
 *
 * @author coder
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class CustomUserDetails extends User {

    private static final long serialVersionUID = 1L;
    private String id;
    private LocalDateTime lastPasswordReset;
    private String departId;
    private String departName;
    private String departKind;
    private String realName;
    private boolean isAdmin;
    private boolean isFirst;

    public CustomUserDetails(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        this(username, password, true, true,
                true, true, authorities);
    }

    public CustomUserDetails(String username, String password,
                             boolean enabled, boolean accountNonExpired,
                             boolean credentialsNonExpired,
                             boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    }
}
